using UnityEngine;
using System.Collections;

public class Character : MonoBehaviour {

	// Use this for initialization
	void Start () {
        m_IsGrounded = false;
	}
	
	// Update is called once per frame
	void Update () {

        float yBot= -1000.0f;
       
        RaycastHit info = new RaycastHit();

        Ray ray = new Ray(transform.position, Vector3.down);
        if (Physics.Raycast(ray, out info)){
            yBot = info.point.y;
        }

        if(Input.GetKey(KeyCode.RightArrow)){
             transform.position += new Vector3(0.5f*Time.deltaTime,0.0f, 0.0f);
        }

        Debug.Log(yBot);
        if (!m_IsGrounded)
        {
            transform.position += new Vector3(0.0f, -0.5f * Time.deltaTime, 0.0f);
            if (transform.position.y < yBot+0.5f)
            {
                transform.position = new Vector3(transform.position.x, yBot+0.5f, transform.position.z);
               
            }
        }


	}
    private bool m_IsGrounded;
}
